﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Entity;
using System.Linq.Expressions;
using VirtualPress.Infrastructure.Entities;
using VirtualPress.Infrastructure.Entities.Repository;

namespace VirtualPress.Portal.Biz
{
    public class PaymentBiz
    {
        public static List<Reckoning> GetAllBill(Expression<Func<T_Reckoning, bool>> where, int page, int pageSize)
        {
            using (Context ctx = new Context())
            {
                return ctx.Reckoning
                    .Where(where)
                    .OrderByDescending(c => c.Id)
                    .Skip(page * pageSize)
                    .Take(pageSize)
                    .ToList()
                    .Select(c => new Reckoning().Set(c))
                    .ToList();
            }
        }
        public static int GetAllBillForPage(Expression<Func<T_Reckoning, bool>> where)
        {
            using (Context ctx = new Context())
            {
                return ctx.Reckoning.Count(where);
            }
        }

    }
}
